<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="city" placeholder="请输入要查询天气的城市">
    <button id="btn">查询</button>
</body>
</html>

<script src="/assets/lib/jquery-1.8.1.min.js"></script>

<script>
    $('#btn').click(function(){
        let city = $.trim($('#city').val());

        if(!city)
        {
            alert('查询的城市名不能为空');

            return false;
        }

        $.ajax({
            type:'post',
            url:'1.php',
            data:{
                city
            },
            dataType:'json',
            success:(result) =>
            {
                console.log(result);
            }
        })
    })
</script>